package cn.bdqn.mybatiesplusvue.dao.impl;

import cn.bdqn.mybatiesplusvue.dao.StudentDao;
import cn.bdqn.mybatiesplusvue.entity.Student;
import cn.bdqn.mybatiesplusvue.service.StudentService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.lang.invoke.LambdaMetafactory;

@Service
public class StudentServiceImpl extends ServiceImpl<StudentDao,Student> implements StudentService {
    @Autowired
    StudentDao studentDao;
    @Override
    public Page getPage(String stuName,Integer pageNum) {
        Page page=new Page(pageNum,3);
        LambdaQueryWrapper<Student> queryWrapper=new LambdaQueryWrapper<>();
        if (StringUtils.hasText(stuName)){
            queryWrapper.like(Student::getStudentname,stuName);
        }
        queryWrapper.orderByDesc(Student::getId);
        return this.page(page, queryWrapper);
    }
}
